<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="p" uri="/WEB-INF/tld/pagination.tld"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>BOM组管理信息</title>
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/css/public.css">
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/sorttable.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/public.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/validate.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/baseset.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/date1.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/checkboxSelect.js"></script>

		<script type="text/javascript">		
	  	function validate(){	
	  	//alert("test");
			var username = document.getElementById("username");
			var rolename = document.getElementById("rolename");
					
			if(!isNotNull(username,'用户名称')||!f_check_ZhOrNumOrLett(username,'用户名称'))
				return false;	
			
			if(!(isNotNull(rolename,'用户组')&&f_check_ZhOrNumOrLett(rolename,'用户组')))
				return false;	
		} 
		
		function getBOMBill(){			
			var formname = document.getElementById("BOMForm");//form的ID
			formname.action = "getBOMBill.action";
				formname.submit();
		}
		
		function showAddBOMBill(){
			var formname = document.getElementById("BOMForm");//form的ID
			formname.action = "showAddBOMBill.action";
			formname.submit();
		}
		
		function showEditBOMBill(){			
			var bomBillIds = document.getElementsByName("bomBillId");
			
			var editID="";
			var formname = document.getElementById("BOMForm");//form的ID

			var bomBillIDCount = 0;
			
	
			for (var i = 0; i < bomBillIds.length; i++) {
				if (bomBillIds[i].checked) {
					bomBillIDCount++;
					editID = editID+bomBillIds[i].value+",";
				}
			}
			var array = editID.split(",");	
			if (bomBillIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} else if (bomBillIDCount>1){
				alert("每次只能修改一条BOM单记录！");
				return false;
			}else{
				if (confirm("确认要修改该记录吗？")) {
					formname.action = "showEditBOMBill.action?editBOMBillID="+array[0];
					formname.submit();
				}			
			}
			
		}
		
		function deleteBOMBill(){
		var bomBillIds = document.getElementsByName("bomBillId");
			
			var deletedBomBillIDs="";
			
			var formname = document.getElementById("BOMForm");//formd的ID

			var bomBillIDCount = 0;
			
	
			for (var i = 0; i < bomBillIds.length; i++) {
				if (bomBillIds[i].checked) {
					bomBillIDCount++;
					deletedBomBillIDs = deletedBomBillIDs+bomBillIds[i].value+",";
				}
			}
	
			if (bomBillIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (confirm("确认要删除记录吗？")) {
				formname.action = "deleteBOMBill.action?deletedBOMBillID="+deletedBomBillIDs;
				formname.submit();
			}
		}
		
		//使用BOM单
		function useBomBill(){
			var bomBillIDs = document.getElementsByName("bomBillId");
			
			var useBomBillID="";
			
			var formname = document.getElementById("BOMForm");//formd的ID

			var useBomBillIDCount = 0;
	
			for (var i = 0; i < bomBillIDs.length; i++) {
				if (bomBillIDs[i].checked) {
					useBomBillIDCount++;
					useBomBillID = useBomBillID+bomBillIDs[i].value+",";
				}
			}
			
			var array = useBomBillID.split(",");
			
			if (useBomBillIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (useBomBillIDCount >1) {
				alert("每次使用BOM单只能选择一条记录！");
				return false;
			} 
				if (useBomBillIDCount == 1) {
					if (confirm("确认要使用该BOM单吗？")) {
						formname.action = "useBomBill.action?useBomBillID="+array[0];
						formname.submit();
					}
				}
		}
		
		//反使用BOM单
		function antiUseBomBill(){
			var bomBillIDs = document.getElementsByName("bomBillId");
			
			var useBomBillID="";
			
			var formname = document.getElementById("BOMForm");//formd的ID

			var useBomBillIDCount = 0;
	
			for (var i = 0; i < bomBillIDs.length; i++) {
				if (bomBillIDs[i].checked) {
					useBomBillIDCount++;
					useBomBillID = useBomBillID+bomBillIDs[i].value+",";
				}
			}
			
			var array = useBomBillID.split(",");
			
			if (useBomBillIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (useBomBillIDCount >1) {
				alert("每次使用BOM单只能选择一条记录！");
				return false;
			} 
				if (useBomBillIDCount == 1) {
					if (confirm("确认要反使用该BOM单吗？")) {
						formname.action = "antiUseBomBill.action?useBomBillID="+array[0];
						formname.submit();
					}
				}
		}
		
		//审核BOM单
		function auditBomBill(){
			var bomBillIDs = document.getElementsByName("bomBillId");
			
			var useBomBillID="";
			
			var formname = document.getElementById("BOMForm");//formd的ID

			var useBomBillIDCount = 0;
	
			for (var i = 0; i < bomBillIDs.length; i++) {
				if (bomBillIDs[i].checked) {
					useBomBillIDCount++;
					useBomBillID = useBomBillID+bomBillIDs[i].value+",";
				}
			}
			var array = useBomBillID.split(",");
			if (useBomBillIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (useBomBillIDCount >1) {
				alert("每次使用BOM单只能选择一条记录！");
				return false;
			} 
				if (useBomBillIDCount == 1) {
					if (confirm("确认要审核该BOM单吗？")) {
						formname.action = "auditBomBill.action?useBomBillID="+array[0];
						formname.submit();
					}
				}
			
			
		}
		
		//反审核BOM单
		function antiAuditBomBill(){
			var bomBillIDs = document.getElementsByName("bomBillId");
			
			var useBomBillID="";
			
			var formname = document.getElementById("BOMForm");//formd的ID

			var useBomBillIDCount = 0;
	
			for (var i = 0; i < bomBillIDs.length; i++) {
				if (bomBillIDs[i].checked) {
					useBomBillIDCount++;
					useBomBillID = useBomBillID+bomBillIDs[i].value+",";
				}
			}
			
			var array = useBomBillID.split(",");
			
			if (useBomBillIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			
			if (useBomBillIDCount >1) {
				alert("每次使用BOM单只能选择一条记录！");
				return false;
			} 
				if (useBomBillIDCount == 1) {
					if (confirm("确认要反审核该BOM单吗？")) {
						formname.action = "antiAuditBomBill.action?useBomBillID="+array[0];
						formname.submit();
					}
				}
			
			
		}
		
		function copyBomBill(){
		var bomBillIDs = document.getElementsByName("bomBillId");
			
			var useBomBillID="";
			
			var formname = document.getElementById("BOMForm");//formd的ID

			var useBomBillIDCount = 0;
	
			for (var i = 0; i < bomBillIDs.length; i++) {
				if (bomBillIDs[i].checked) {
					useBomBillIDCount++;
					useBomBillID = useBomBillID+bomBillIDs[i].value+",";
				}
			}
			
			var array = useBomBillID.split(",");
			
			if (useBomBillIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (useBomBillIDCount >1) {
				alert("每次使用BOM单只能选择一条记录！");
				return false;
			} 
				if (useBomBillIDCount == 1) {
					if (confirm("确认要复制该BOM单吗？")) {
						formname.action = "copyBOMBill.action?useBomBillID="+array[0];
						formname.submit();
					}
				}
		}
		
		function goToBomGroup(){
		var formname = document.getElementById("BOMForm");//formd的ID
		formname.action = "showBOMGroupList.action";
						formname.submit();
		}
		
		
	
		</script>

	</head>
	<body>
		<s:form name="BOMForm" theme="simple" cssStyle="margin-top:0px"
			id="BOMForm">
			<input type="hidden" name="bomGroupId" id="bomGroupId"
				value="${bomGroupID}" />
			<div id="info_all">
				<div id="info_top">
					BOM管理
				</div>
				<!-- 主输入区 -->
				<!-- 功能按钮 -->

				<div id="btn">
					<input type="button" value="增加" onClick="showAddBOMBill()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="修改" onClick="showEditBOMBill()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="删除" onClick="deleteBOMBill()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="使用" onClick="useBomBill()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="反使用" onClick="antiUseBomBill()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="审核" onClick="auditBomBill()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="反审核" onClick="antiAuditBomBill()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="复制" onClick="copyBomBill()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="button" value="返回BOM组" onClick="goToBomGroup()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
					&nbsp;&nbsp;
				</div>
				<div id="info_main">
					<div id="select">
						<hr>
						<table>
							<tr>
								<td>
									BOM单编号&nbsp;
								</td>
								<td>
									<input type="text" name="bomBillCode" size="12">
									&nbsp;&nbsp;&nbsp;
								</td>


								<td>
									使用状态&nbsp;
								</td>
								<td>

									<s:select cssStyle="width:96px" name="state"
										list="#{'2':'全部','0':'未使用','1':'使用'}" />
									&nbsp;&nbsp;&nbsp;
								</td>

								<td>
									审核状态
								</td>
								<td width="100px">
									<s:select cssStyle="width:96px" name="auditState"
										list="#{'2':'全部','0':'未审核','1':'审核'}" />

								</td>
							</tr>
						</table>
					</div>
					<div class="sele">
						<input type="button" value="查询" onFocus="this.blur()"
							onmouseover="this.className='btnover'" onClick="getBOMBill()"
							onmouseout="this.className='btnout'" class="btnsize" />

						<input type="reset" value="重置" onFocus="this.blur()"
							onmouseover="this.className='btnover'"
							onmouseout="this.className='btnout'" class="btnsize" />
						<hr>
					</div>

					<!-- 信息显示栏 -->
					<div id="info_info1">

						<table width="1080px" height="" cellpadding="1" cellspacing="1"
							class="sortable" id="info_table">
							<thead>
								<tr>
									<th>
										<input type="checkbox" name="checkbox" onClick="selectAll()" />
									</th>
									<th width="80px">
										BOM编号
									</th>
									<th width="80px">
										BOM组别
									</th>
									<th width="80px">
										物料代码
									</th>
									<th width="80px">
										物料名称
									</th>
									<th width="80px">
										规格型号
									</th>
									<th width="80px">
										物料属性
									</th>
									<th width="80px">
										数量
									</th>
									<th width="80px">
										单位
									</th>
									<th width="80px">
										使用状态
									</th>
									<th width="80px">
										审核状态
									</th>
									<th width="80px">
										费用
									</th>
									<th width="80px">
										备注
									</th>
									<th width="120px">
										查看BOM单明细
									</th>
								</tr>
							</thead>
							<tbody id="mbody">
								<s:iterator value="bomBillDTOList" status="status">
									<tr>
										<td>
											<input type="checkbox" name="bomBillId" id="bomBillId"
												value="${bomBillId}" />
										</td>
										<td>
											<s:property value="bomBillCode" />
										</td>
										<td>
											<s:property value="bomGroupName" />
										</td>
										<td>
											<s:property value="verifyProjectMaterialCode" />
										</td>
										<td>
											<s:property value="verifyProjectMaterialName" />
										</td>
										<td>
											<s:property value="verifyProjectMaterialSpec" />
										</td>
										<td>
											<s:property value="verifyProjectMaterialMaterialAttribute" />
										</td>
										<td>
											<s:property value="number" />
										</td>
										<td>
											<s:property value="unit" />
										</td>
										<td>
											<s:property value="state" />
										</td>
										<td>
											<s:property value="auditState" />
										</td>
										<td>
											<s:property value="fee" />
										</td>
										<td>
											<s:property value="memo" />
										</td>
										<td>
											<a href="showBOMBillDetail.action?bomBillID=${bomBillId}">查看</a>
										</td>
									</tr>
								</s:iterator>
							</tbody>
							<tfoot>
								<tr></tr>
							</tfoot>
						</table>
						<s:if test="!bomBillDTOList.isEmpty">
							<tr style="font-size: 12px;">

								<div align="center">
									<font color="#FF0000"> 共<s:property value="page.total" />
										页 第 <s:property value="page.cpage" /> 页 <p:page
											cpage="%{page.cpage}" total="%{page.total}" url="%{page.url}" />
									</font>

								</div>
							</tr>
						</s:if>

					</div>
		</s:form>
	</body>
</html>